#pragma once

#ifndef QueryPreProcessor_h
#define QueryPreProcessor_H

#include "PKB.h"
#include "Standards.h"

class QueryPreProcessor {
	public:
		QueryPreProcessor(PKB*);
		vector<vector<string>> processQuery(string);
	private:
		PKB* myPKB;
		NAME operand;
		bool fail;
		int globalClauseCounter;
		string isCount;
		string isCallProcName;
		DESIGN_ENTITY operandType;
		RELATION relation;
		NAME relationfirstParam; 
		NAME relationsecondParam;
		vector<string> result;
		vector<string> selectR;
		vector<string> tokens;
		unordered_map<NAME, DESIGN_ENTITY> synTable;
		unordered_map<NAME, set<INDEX>> commonsTable;		
		vector<vector<string>> parsed;
		void Such(int, int);
		void Pattern(int, int);
		void With(string);
		void validateNAME(string);
		bool match(string, string);
		bool match(string, string, string, string, string);
		bool isInteger(string);

		int numDigits(int);
		string getParamType(string);
		string getParamTypeEntityRef(string);
		void validateNAMEINTEGER(string);
		bool hasEndsWith(string, char);
		bool checkNAME(string);
		void validateIDENT(string);

		vector<string> finalPackage;
		vector<string> withPackage;
		vector<string> SpaceAdjuster(vector<string>, char);
		vector<string> SAremoveSpaceFront(vector<string>, char);
		vector<string> SpaceAdjusterV3(vector<string>, char);
		vector<string> SAremoveSpaceRear(vector<string>, char);
};
#endif